package com.lipuwater.agent.http.api;

import android.content.Context;

import com.lipuwater.agent.http.ApiCallBack;
import com.lipuwater.agent.http.BaseRequest;
import com.lipuwater.agent.http.HttpConfig;
import com.lipuwater.agent.ui.dialog.LoadingDialog;
import com.okhttplib.OkHttpUtils;

import java.util.Map;

import static com.lipuwater.agent.http.HttpConfig.API_;


/**
 * 　　　┏┓　　　┏┓
 * 　　┏┛┻━━━┛┻┓
 * 　　┃　　　　　　　┃
 * 　　┃　　　━　　　┃
 * 　　┃　┳┛　┗┳　┃
 * 　　┃　　　　　　　┃
 * 　　┃　　　┻　　　┃
 * 　　┃　　　　　　　┃
 * 　　┗━┓　　　┏━┛
 * 　　　　┃　　　┃神兽保佑
 * 　　　　┃　　　┃永无BUG！
 * 　　　　┃　　　┗━━━┓
 * 　　　　┃　　　　　　　┣┓
 * 　　　　┃　　　　　　　┏┛
 * 　　　　┗┓┓┏━┳┓┏┛
 * 　　　　　┃┫┫　┃┫┫
 * 　　　　　┗┻┛　┗┻┛
 * ━━━━━━神兽出没━━━━━━
 * Created by  Administrator  on 2016/12/5.
 * Email:924686754@qq.com
 * 基础接口:登录、注册...
 */
public class ApiRequestsBasis {
    private static BaseRequest baseRequest = BaseRequest.getInstance();


    /**
     * 用户登录
     *
     * @param context
     * @param params
     * @param callback
     */
    public static void Login(Context context, Map<String, Object> params, ApiCallBack callback) {
        baseRequest.sendRequestPost(context, API_ + "distributorapi/login", params, callback, null);
    }

    /**
     * 获取首页数据
     *
     * @param context
     * @param params
     * @param callback
     */
    public static void getHomeData(Context context, Map<String, Object> params, ApiCallBack callback) {
        LoadingDialog dialog = new LoadingDialog(context);
        baseRequest.sendRequestPost(context, API_ + "wpPurchaseOrder/getIndexData", params, callback, dialog);
    }

    /**
     * 获取商城产品列表
     *
     * @param object
     * @param params
     * @param callback
     */
    public static void getProductList(Object object, Map<String, Object> params, ApiCallBack callback) {
        baseRequest.sendRequestPost(object, API_ + "good/findGoodList", params, callback, null);
    }

    /**
     * 获取商城产品详情
     *
     * @param object
     * @param params
     * @param callback
     */
    public static void getProductDes(Object object, Map<String, Object> params, ApiCallBack callback) {
        baseRequest.sendRequestPost(object, API_ + "good/getGoodDetail", params, callback, null);
    }

    /**
     * 获取销售单列表
     *
     * @param params
     * @param callback
     */
    public static void getSalesList(Object object, Map<String, Object> params, ApiCallBack callback) {
        baseRequest.sendRequestPost(object, API_ + "wpPurchaseOrder/getorderlist", params, callback, null);
    }

    /**
     * 获取销售单详情
     *
     * @param object
     * @param params
     * @param callback
     */
    public static void getSalesDes(Object object, Map<String, Object> params, ApiCallBack callback) {
        baseRequest.sendRequestPost(object, API_ + "wpPurchaseOrder/getorderdetail", params, callback, null);
    }

    /**
     * 获取安装单列表
     *
     * @param object
     * @param params
     * @param callback
     */
    public static void getInstallList(Object object, Map<String, Object> params, ApiCallBack callback) {
        baseRequest.sendRequestPost(object, API_ + "workorderapi/installlist", params, callback, null);
    }

    /**
     * 获取安装单详情
     *
     * @param object
     * @param params
     * @param callback
     */
    public static void getInstallDes(Object object, Map<String, Object> params, ApiCallBack callback) {
        baseRequest.sendRequestPost(object, API_ + "workorderapi/installdetail", params, callback, null);
    }

    /**
     * 获取售后单列表
     *
     * @param object
     * @param params
     * @param callback
     */
    public static void getAfterList(Object object, Map<String, Object> params, ApiCallBack callback) {
        baseRequest.sendRequestPost(object, API_ + "workorderapi/aftersalelist", params, callback, null);
    }

    /**
     * 获取售后单详情
     *
     * @param object
     * @param params
     * @param callback
     */
    public static void getAfterDes(Object object, Map<String, Object> params, ApiCallBack callback) {
        baseRequest.sendRequestPost(object, API_ + "workorderapi/aftersaledetail", params, callback, null);
    }

    /**
     * 获取职员列表
     *
     * @param object
     * @param params
     * @param callback
     */
    public static void getPersonnelList(Object object, Map<String, Object> params, ApiCallBack callback) {
        baseRequest.sendRequestPost(object, API_ + "personnelmanagement/getuserlist", params, callback, null);
    }

    /**
     * 获取所有角色列表
     *
     * @param object
     * @param params
     * @param callback
     */
    public static void getRoles(Object object, Map<String, Object> params, ApiCallBack callback) {
        baseRequest.sendRequestPost(object, API_ + "personnelmanagement/findRoles", params, callback, null);
    }

    /**
     * 更新职员信息
     *
     * @param context
     * @param params
     * @param callback
     */
    public static void upDatePersonnel(Context context, Map<String, Object> params, ApiCallBack callback) {
        LoadingDialog dialog = new LoadingDialog(context);
        baseRequest.sendRequestPost(context, API_ + "wpPurchaseOrder/updateUser", params, callback, dialog);
    }

    /**
     * 获取我的账户信息
     *
     * @param object
     * @param params
     * @param callback
     */
    public static void getAccount(Object object, Map<String, Object> params, ApiCallBack callback) {
        baseRequest.sendRequestPost(object, API_ + "personnelmanagement/accountmanagement", params, callback, null);
    }

    /**
     * 获取我的消息列表
     *
     * @param object
     * @param params
     * @param callback
     */
    public static void getMessage(Object object, Map<String, Object> params, ApiCallBack callback) {
        baseRequest.sendRequestPost(object, API_ + "message/getmessagelist", params, callback, null);
    }

    /**
     * 更新用户信息
     *
     * @param context
     * @param params
     * @param callback
     */
    public static void updateUserInfo(Context context, Map<String, Object> params, ApiCallBack callback) {
        LoadingDialog dialog = new LoadingDialog(context, "更新中");
        baseRequest.sendRequestPost(context, API_ + "wpPurchaseOrder/updateInfo", params, callback, dialog);
    }

    /**
     * 获取销售安装排名列表
     *
     * @param context
     * @param params
     * @param callback
     */
    public static void getRanking(Context context, Map<String, Object> params, ApiCallBack callback) {
        baseRequest.sendRequestPost(context, API_ + "wpPurchaseOrder/findRanking", params, callback, null);
    }

    /**
     * 提交生成订单信息
     *
     * @param context
     * @param params
     * @param callback
     */
    public static void postOrder(Context context, Map<String, Object> params, ApiCallBack callback) {
        LoadingDialog dialog = new LoadingDialog(context);
        baseRequest.sendRequestPost(context, API_ + "wpPurchaseOrder/dsPurchaseOrder", params, callback, dialog);
    }

    /**
     * 销售单确认收款
     *
     * @param context
     * @param params
     * @param callback
     */
    public static void updateOrderState(Context context, Map<String, Object> params, ApiCallBack callback) {
        LoadingDialog dialog = new LoadingDialog(context);
        baseRequest.sendRequestPost(context, API_ + "wpPurchaseOrder/updateOrderState", params, callback, dialog);
    }


    /**
     * 分配安装工单
     *
     * @param context
     * @param params
     * @param callback
     */
    public static void allotInstall(Context context, Map<String, Object> params, ApiCallBack callback) {
        LoadingDialog dialog = new LoadingDialog(context);
        baseRequest.sendRequestPost(context, API_ + "workorderapi/assignWorkOrder", params, callback, dialog);
    }

    /**
     * 提交反馈
     *
     * @param context
     * @param params
     * @param callback
     */
    public static void PostFeedback(Context context, Map<String, Object> params, ApiCallBack callback) {
        LoadingDialog dialog = new LoadingDialog(context);
        baseRequest.sendRequestPost(context, API_ + "member/feedbackbyuser", params, callback, dialog);
    }

    /**
     * 获取可服务地区
     *
     * @param context
     * @param params
     * @param callback
     */
    public static void getServiceRange(Context context, Map<String, Object> params, ApiCallBack callback) {
        baseRequest.sendRequestPost(context, API_ + "distributor/findServiceRange", params, callback, null);
    }

    /**
     * 校验开单的时候输入的客户手机号码是否已经推荐
     *
     * @param context
     * @param params
     * @param callback
     */
    public static void checkCustomerPhone(Context context, Map<String, Object> params, ApiCallBack callback) {
        baseRequest.sendRequestPost(context, API_ + "wpPurchaseOrder/checkCustomerPhone", params, callback, null);
    }

    /**
     * 获取验证码
     *
     * @param context
     * @param callback
     */
    public static void getVCode(Context context, Map<String, Object> params, ApiCallBack callback) {
        LoadingDialog dialog = new LoadingDialog(context);
        baseRequest.sendRequestPost(context, HttpConfig.API_ + "v1.2/common/getvalidatecode", params, callback, dialog);
    }

    public static void findPassWord(Context context, Map<String, Object> params, ApiCallBack callback) {
        LoadingDialog dialog = new LoadingDialog(context);
        baseRequest.sendRequestPost(context, HttpConfig.API_ + "v1.2/agent/retrievalpwd", params, callback, dialog);

    }
    /**
     * 绑定个推ClientId
     * @param params
     * @param callback
     */
    public static void biningClientId(Object object, Map<String, Object> params, ApiCallBack callback) {
        baseRequest.sendRequestPost(object, HttpConfig.API_ + "v1.2/common/getclientid", params, callback, null);
    }

    /**
     * 取消对象的所有请求
     *
     * @param object
     */
    public static void cancelRequests(Object object) {
        OkHttpUtils.getInstance().cancelTag(object);
    }

}
